home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-posrte.ads < prev    next >
Text File  |  1994-05-19  |  8KB  |  206 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                      S Y S T E M . P O S I X _ R T E                     --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.6 $                             --
  10. --                                                                          --
  11. --           Copyright (c) 1991,1992,1993, FSU, All Rights Reserved         --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or (at  your  option)  any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package interfaces with the POSIX real-time extensions.  It may
  27. --  also implement some of them using UNIX operations. It is not a complete
  28. --  interface, it only includes what is needed to implement the Ada runtime.
  29.  
  30. --  temporarily, should really only be for 1 ???
  31. with System.POSIX_ERROR; use System.POSIX_ERROR;
  32.  
  33. with System.POSIX_Constants;
  34.  
  35. package System.POSIX_RTE is
  36.  
  37.    type Byte is range 0 .. 2#1#E8 - 1;
  38.    for Byte'SIZE use 8;
  39.    type Halfword is range 0 .. 2#1#E16 - 1;
  40.    for Halfword'SIZE use 16;
  41.  
  42.    type Word is new Integer;
  43.    for Word'SIZE use 32;
  44.    --  Was System.Address; changed to Integer to make GNAT happy.
  45.  
  46.    --  The following definitions are from P1003.5,
  47.    --  which the rest of this package is not.
  48.    type Signal is range 0 .. 31;
  49.    for Signal'Size use 32;
  50.    type Signal_Set is private;
  51.  
  52.    procedure Add_Signal
  53.      (Set : in out Signal_Set;
  54.       Sig : in Signal);
  55.    procedure Add_All_Signals (Set : in out Signal_Set);
  56.    procedure Delete_Signal
  57.      (Set : in out Signal_Set;
  58.       Sig : in Signal);
  59.    procedure Delete_All_Signals (Set : in out Signal_Set);
  60.    function Is_Member
  61.      (Set : Signal_Set;
  62.       Sig : Signal)
  63.      return Boolean;
  64.    --  End of P1003.5 definitions.
  65.  
  66.    type sigval is record
  67.       u0 : Integer;
  68.    end record;
  69.    --  This is not used at the moment, need to update to reflect
  70.    --  any changes in the Pthreads signal.h in the future
  71.  
  72.    type struct_siginfo is record
  73.       si_signo : Signal;
  74.       si_code : Integer;
  75.       si_value : sigval;
  76.    end record;
  77.  
  78.    type siginfo_ptr is access struct_siginfo;
  79.  
  80.    type sigset_t_ptr is access Signal_Set;
  81.  
  82.    SIG_ERR : constant := POSIX_Constants.SIG_ERR;
  83.    SIG_DFL : constant := POSIX_Constants.SIG_DFL;
  84.    SIG_IGN : constant := POSIX_Constants.SIG_IGN;
  85.    --  constants for sa_handler
  86.  
  87.    type struct_sigaction is record
  88.  
  89.       sa_handler : System.Address;
  90.       --  address of signal handler
  91.  
  92.       sa_mask : Signal_Set;
  93.       --  Additional signals to be blocked during
  94.       --  execution of signal-catching function
  95.  
  96.       sa_flags : Integer;
  97.       --  Special flags to affect behavior of signal
  98.  
  99.    end record;
  100.  
  101.    --  Signal catching function (signal handler) has the following profile :
  102.  
  103.    --  procedure Signal_Handler
  104.    --    (signo   : Signal;
  105.    --     info    : siginfo_ptr;
  106.    --     context : sigcontext_ptr);
  107.  
  108.    SA_NOCLDSTOP : constant := POSIX_Constants.SA_NOCLDSTOP;
  109.    --  Don't send a SIGCHLD on child stop
  110.  
  111.    SA_SIGINFO : constant := POSIX_Constants.SA_SIGINFO;
  112.    --  sa_flags flags for struct_sigaction
  113.  
  114.    SIG_BLOCK   : constant := POSIX_Constants.SIG_BLOCK;
  115.    SIG_UNBLOCK : constant := POSIX_Constants.SIG_UNBLOCK;
  116.    SIG_SETMASK : constant := POSIX_Constants.SIG_SETMASK;
  117.    --  sigprocmask flags (how)
  118.  
  119.    type jmp_buf is array
  120.      (1 .. POSIX_Constants.pthread_jmp_buf_size) of Integer;
  121.  
  122.    type sigjmp_buf is array
  123.      (1 .. POSIX_Constants.pthread_sigjmp_buf_size) of Integer;
  124.  
  125.    type jmp_buf_ptr is access jmp_buf;
  126.  
  127.    type sigjmp_buf_ptr is access sigjmp_buf;
  128.    --  Environment for long jumps
  129.  
  130.    procedure sigaction
  131.      (sig    : Signal;
  132.       act    : struct_sigaction;
  133.       oact   : out struct_sigaction;
  134.       Result : out POSIX_Error.Return_Code);
  135.    pragma Inline (sigaction);
  136.    --  install new sigaction structure and obtain old one
  137.  
  138.    procedure sigprocmask
  139.      (how    : Integer;
  140.       set    : Signal_Set;
  141.       oset   : out Signal_Set;
  142.       Result : out POSIX_Error.Return_Code);
  143.    pragma Inline (sigprocmask);
  144.    --  Install new signal mask and obtain old one
  145.  
  146.    procedure sigsuspend (mask : Signal_Set; Result : out Return_Code);
  147.    pragma Inline (sigsuspend);
  148.    --  Suspend waiting for signals in mask and resume after
  149.    --  executing handler or take default action
  150.  
  151.    procedure sigpending (set : out Signal_Set; Result : out Return_Code);
  152.    pragma Inline (sigpending);
  153.    --  get pending signals on thread and process
  154.  
  155.    procedure longjmp (env : jmp_buf; val : Integer);
  156.    pragma Inline (longjmp);
  157.    --  execute a jump across procedures according to setjmp
  158.  
  159.    procedure siglongjmp (env : sigjmp_buf; val : Integer);
  160.    pragma Inline (siglongjmp);
  161.    --  execute a jump across procedures according to sigsetjmp
  162.  
  163.    procedure setjmp (env : jmp_buf; Result : out Integer);
  164.    pragma Inline (setjmp);
  165.    --  set up a jump across procedures and return here with longjmp
  166.  
  167.    procedure sigsetjmp
  168.      (env      : sigjmp_buf;
  169.       savemask : Integer;
  170.       Result   : out Integer);
  171.    pragma Inline (sigsetjmp);
  172.    --  Set up a jump across procedures and return here with siglongjmp
  173.  
  174.    --  temporarily, should really only be for 1 ???
  175.  
  176.    Signal_Kill, SIGKILL : constant Signal := POSIX_Constants.SIGKILL;
  177.    Signal_Stop, SIGSTOP : constant Signal := POSIX_Constants.SIGSTOP;
  178.    --  signals which cannot be masked
  179.  
  180.    Signal_Illegal_Instruction, SIGILL  : constant Signal :=
  181.          POSIX_Constants.SIGILL;
  182.    Signal_Abort, SIGABRT : constant Signal := POSIX_Constants.SIGABRT;
  183.    SIGEMT  : constant Signal := POSIX_Constants.SIGEMT;
  184.    Signal_Floating_Point_Error, SIGFPE  : constant Signal :=
  185.          POSIX_Constants.SIGFPE;
  186.    SIGBUS  : constant Signal := POSIX_Constants.SIGBUS;
  187.    SIGSEGV : constant Signal := POSIX_Constants.SIGSEGV;
  188.    Signal_Pipe_Write, SIGPIPE : constant Signal := POSIX_Constants.SIGPIPE;
  189.    --  some synchronous signals (cannot be used for interrupt entries)
  190.  
  191.    Signal_Alarm, SIGALRM : constant Signal := POSIX_Constants.SIGALRM;
  192.    --  alarm signal (cannot be used for interrupt entries)
  193.  
  194.    Signal_User_1, SIGUSR1 : constant Signal := POSIX_Constants.SIGUSR1;
  195.    Signal_User_2, SIGUSR2 : constant Signal := POSIX_Constants.SIGUSR2;
  196.    --  user-defined signals
  197.  
  198.    SIGTRAP : constant Signal := POSIX_Constants.SIGTRAP;
  199.    --  Not POSIX; this is left unmasked to keep SGI dbx happy.
  200.  
  201. private
  202.  
  203.    type Signal_Set is array (1 .. POSIX_Constants.posix_sigset_t_size) of Byte;
  204.  
  205. end System.POSIX_RTE;
  206.